﻿Public Class Logger
    Dim _frm As frmMain

    Sub New(ByVal frm As frmMain)
        _frm = frm
    End Sub

    Sub Log(ByVal str As String)
        If _frm.InvokeRequired Then
            _frm.Invoke(Sub()
                            _frm.rtbLog.AppendText("[" & TimeOfDay & "] " & str & vbNewLine)
                            _frm.rtbLog.SelectionStart = _frm.rtbLog.Text.Length
                            _frm.rtbLog.ScrollToCaret()
                        End Sub)
        Else
            _frm.rtbLog.AppendText("[" & TimeOfDay & "] " & str & vbNewLine)
            _frm.rtbLog.SelectionStart = _frm.rtbLog.Text.Length
            _frm.rtbLog.ScrollToCaret()
        End If
    End Sub
End Class
